package org.korifey.ffbdd.samples.assign;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Timetable {
	List<List<Integer>> consumer = new ArrayList<List<Integer>>();
	
	/**
	 * Format:
	 * nconsumers
	 * 
	 */
	public void parse(InputStream is) throws Exception{
		BufferedReader reader = new BufferedReader(new InputStreamReader(is));
		consumer = new ArrayList<List<Integer>>();
		
		
		for (String line = reader.readLine(); line != null; line = reader.readLine()) {
			line = line.trim();
			if (line.equals("") || line.startsWith("#")) continue;
			StringTokenizer tk = new StringTokenizer(line);
			List<Integer> lst = new ArrayList<Integer>();
			while (tk.hasMoreTokens()) {
				lst.add(Integer.parseInt(tk.nextToken()));
			}
			consumer.add(lst);
		}
	}
	
	public int getSize() {
		return consumer.size();
	}
	
	public List<Integer> getConsumerResources(int index) {
		return consumer.get(index);
	}
}
